import type { Dayjs } from 'dayjs';

import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace EdubaseSemesterWeekApi {
  /** 学期周次信息 */
  export interface SemesterWeek {
    id: number; // 周主键ID
    academicYearId?: number; // 学年id
    academicYear: string; // 学年
    period?: number; // 学段
    semesterId?: number; // 学期ID
    semesterCode: string; // 学期编码
    weekNumber?: number; // 周次
    weekType?: number; // 周类型
    startDate?: Dayjs | string; // 周开始日期
    endDate?: Dayjs | string; // 周结束日期
    isTeachingWeek: number; // 是否教学周
    isExamWeek: number; // 是否考试周
    isHolidayWeek: number; // 是否假期周
    remark: string; // 备注
  }
}

/** 查询学期周次分页 */
export function getSemesterWeekPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<EdubaseSemesterWeekApi.SemesterWeek>>(
    '/edu/base/semester-week/page',
    data,
    { desensitize, encrypt },
  );
}

/** 查询学期周次详情 */
export function getSemesterWeek(id: number) {
  return requestClient.get<EdubaseSemesterWeekApi.SemesterWeek>(
    `/edu/base/semester-week/get?id=${id}`,
  );
}

/** 新增学期周次 */
export function createSemesterWeek(data: EdubaseSemesterWeekApi.SemesterWeek) {
  return requestClient.post('/edu/base/semester-week/create', data);
}

/** 修改学期周次 */
export function updateSemesterWeek(data: EdubaseSemesterWeekApi.SemesterWeek) {
  return requestClient.put('/edu/base/semester-week/update', data);
}

/** 删除学期周次 */
export function deleteSemesterWeek(id: number) {
  return requestClient.delete(`/edu/base/semester-week/delete?id=${id}`);
}

/** 批量删除学期周次 */
export function deleteSemesterWeekList(ids: number[]) {
  return requestClient.delete(
    `/edu/base/semester-week/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出学期周次 */
export function exportSemesterWeek(params: any) {
  return requestClient.download('/edu/base/semester-week/export-excel', {
    params,
  });
}

/** 初始化学期周次 */
export function initSemesterWeek(semesterId: number) {
  return requestClient.get(
    `/edu/base/semester-week/init?semesterId=${semesterId}`,
  );
}
